home *** CD-ROM | disk | FTP | other *** search
-
- #include <hfs.h>
- #include <quickdraw.h>
- #include <stdio.h>
-
- #ifndef NULL
- #define NULL 0L
- #endif
-
- main()
- {
- init_mac();
- dump_wds();
- }
-
- dump_wds()
- {
- WDPBRec pb;
- int the_vol, count, error, c;
- unsigned char *ptr;
- unsigned char cname[256];
-
- pb.ioCompletion = NULL;
- pb.ioNamePtr = NULL;
- if ( error = PBHGetVol (&pb, FALSE) )
- {
- printf ("\nPBHGetVol error %d", error);
- return;
- }
- the_vol = pb.ioWDVRefNum;
-
- again:
- count = 1;
- pb.ioCompletion = NULL;
- pb.ioNamePtr = NULL; /* gives volume name back */
- while ( TRUE )
- {
- pb.ioVRefNum = the_vol;
- pb.ioWDVRefNum = the_vol;
- pb.ioWDIndex = count++;
- pb.ioWDProcID = 0 /*'IRWN' */;
- if ( PBGetWDInfo (&pb, FALSE) )
- break; /* none left */
-
- /* now print them */
- ptr = (unsigned char *)&pb.ioWDProcID;
- printf ("\n wd '%c%c%c%c' %10ld", ptr[0], ptr[1], ptr[2], ptr[3], pb.ioWDDirID);
- get_dir_name(the_vol, pb.ioWDDirID, cname);
- printf (" '%s'", cname);
- }
-
- printf("\n\nPress 'z' to do again, other key to exit");
- if ( ( c=getchar() ) == 'z' )
- goto again;
- }
-
- int get_dir_name(vol, dir_id, cname)
- int vol;
- long dir_id;
- unsigned char *cname;
- {
- CInfoPBRec cpb; /* Mac catalog parameter block */
- int error, i;
-
- zero_mem ( (char *)&cpb, sizeof(cpb) );
-
- cpb.dirInfo.ioFDirIndex = -1;
- cpb.dirInfo.ioVRefNum = vol;
- cpb.dirInfo.ioDrDirID = dir_id;
- cpb.dirInfo.ioNamePtr = cname;
-
- error = PBGetCatInfo (&cpb, FALSE); /* Make File Sys request */
-
- if ( error )
- {
- printf ("error %d", error);
- }
- else
- PtoCstr(cname);
- }
-
- /*--------------------------------------
- zero_mem: zeros a block of memory
-
- Passed:
- W BYTE *ptr;
- R UINT len;
-
- --------------------------------------*/
-
- zero_mem ( ptr, len )
- unsigned char *ptr;
- int len;
- {
- while ( len-- )
- *ptr++ = 0;
- }
-
-
- /*---------------*/
- init_mac()
- {
-
- #ifdef NEEDED
- InitGraf (&thePort);
- InitFonts ();
- InitWindows();
- InitCursor ();
- InitMenus ();
- InitDialogs (0L);
- TEInit();
-
- Stdio_MacInit(); /* Tell LightSpeed stdio that we initted toolbox */
- FlushEvents(-1, 0); /* get rid of left over events */
- #endif
- printf(" ");
- }
-